struct Solution {}

impl Solution {
  pub fn convert_to_base7(num: i32) -> String {
  let mut num = num;
  if num == 0 {
    return "0".to_string(); 
  }
  let prefix = if num > 0 { "".to_string() } else { "-".to_string() };
  if num < 0 {
    num = -num;
  }
  let mut ret = "".to_string();
  while num > 0 {
    let t = num % 7;
    ret = t.to_string() + &ret;
    num = num / 7;
  }
  prefix + &ret
  }
}